package com.example.basic.bitmap;

import java.io.*;
import java.util.Arrays;

public class Bitmap {


    static final int[] arr = {1,3,5453,23,546,7686,324,234,65,34,24,63,24,26,2,562,24,63,24,62,24,63,214,63,14,134,356,14};

    public static void main(String[] args) {

        int[] result = new int[313];
        for (int i : arr) {
            int index = i/31;
            int offset = i%31;
            System.out.println("index = " + index + "  offset = " + offset);
            System.out.println("result[index] = " + result[index]  + "  value = " + (1<<offset));
            result[index] |= 2<<offset;
            System.out.println(Integer.toBinaryString(result[index]));
        }

        for (int i : result) {
            System.out.println(FixStr(Integer.toBinaryString(i)));
        }



//        try {
//            writeToFile();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }




    }

    private static String FixStr(String toBinaryString) {
        if (toBinaryString.length() < 32) {
            int dif = 32 - toBinaryString.length();
            int[] fixArr = new int[dif];
            StringBuilder toBinaryStringBuilder = new StringBuilder("");
            for (int i : fixArr) {
                toBinaryStringBuilder.append(i);
            }
            toBinaryString = toBinaryStringBuilder.append(toBinaryString).toString();
        }
        return toBinaryString;
    }

    private static void writeToFile() throws IOException {
        File file = new File("./list.txt");

        FileOutputStream fileWriter = new FileOutputStream(file);
        fileWriter.write(100000000);
        fileWriter.close();
    }


}
